package cn.org.spring.wechar.controller;

import cn.org.spring.wechar.bean.Button;
import cn.org.spring.wechar.bean.ButtonType;
import cn.org.spring.wechar.service.AccessTokenService;
import cn.org.spring.wechar.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;


@RestController
@RequestMapping("/weChar")
public class MenuController {

    @Autowired
    private MenuService menuService;

    @Resource
    private AccessTokenService accessTokenService;

    @GetMapping("/createMenu")
    public void createMenu() throws IOException {
        Button one_1 = Button.ofOneMenu(Button.HEAD, ButtonType.VIEW, "关于我们", "http://www.soso.com");
        Button one_2 = Button.ofOneMenu(one_1, ButtonType.CLICK, "活动", "尚无活动");
        Button one_3 = Button.ofOneMenu(one_2, ButtonType.CLICK, "会员中心", "会员中心");
        Button of = Button.of(one_3, 2, ButtonType.VIEW, "我的会员", "https://www.soso.com");
        Button of1 = Button.of(of, 2, ButtonType.VIEW, "周边商户", "http://www.soso.com");
        Button of2 = Button.of(of1, 2, ButtonType.VIEW, "积分商城", "http://www.baidu.com");
        Button of3 = Button.of(of2, 2, ButtonType.VIEW, "切换用户", "http://www.baidu.com");
        System.out.println(of3.toJson());
        menuService.createMenu(of3);
    }

    @GetMapping("/deleteMenu")
    public void deleteMenu() throws IOException {
        menuService.deleteMenu();
    }


}